package cn.tonyandmoney.voicenotes.greendao.utils

import android.content.Context
import android.database.sqlite.SQLiteDatabase
import cn.tonyandmoney.voicenotes.greendao.gen.*
import com.github.yuweiguocn.library.greendao.MigrationHelper

/**
 * Created by niantuo on 2017/9/23.
 * 数据库的升级辅助类
 */
class SQLiteOpenHelper(context: Context, name: String)
    : DaoMaster.OpenHelper(context, name) {

    init {
        setLoadSQLCipherNativeLibs(false)
    }


    override fun onUpgrade(db: SQLiteDatabase, oldVersion: Int, newVersion: Int) {
        super.onUpgrade(db, oldVersion, newVersion)
        MigrationHelper.DEBUG = true
        MigrationHelper.migrate(db, TNoteDao::class.java,
                NoteRecordDao::class.java,
                TRecordDao::class.java,
                TAlarmDao::class.java)
    }
}